<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/include/include.jsp"%>
<script type="text/javascript">
<!--
	function submitDictForm(form){		
		var tableParams = [{
			selector:'#dictType_dict',
			namePattern:'rmpDicts[+index+].+name+'
		}];
		
		return customerAjaxSubmitForm(form,tableParams);
	}	
//-->
</script>

<div class="pageContent" id="page_${now.time}">
	<form action="<c:if test="${not empty dictType}"><c:url value="/system/dict/edit"/></c:if><c:if test="${empty dictType}"><c:url value="/system/dict/add"/></c:if>" 
		method="post" onsubmit="return submitDictForm(this);">
	<div class="pageFormContent" layoutH="56">
		<fieldset>
			<legend><fmt:message key="page.dict.dicttypeinfo"/></legend>
			
			<dl>
				<dt><fmt:message key="page.dict.dictTypeCode"/>：</dt>
				<dd>
					<input name="code" type="text" size="30" value="${dictType.code}"
					 	<c:if test="${not empty dictType}"> readonly="readonly"</c:if>
					 	<c:if test="${empty dictType}"> onblur="ajaxValidator(this,'<c:url value="/system/dict/validateCode"/>')" </c:if> 
					 	class="required {rangelength:[2,32]}"/>
				</dd>			
			</dl>
			<dl>
				<dt><fmt:message key="page.dict.dictTypeName"/>：</dt>
				<dd>
					<input name="name" type="text" size="30" value="${dictType.name}" class="required"/>
				</dd>
			</dl>
			<dl class="nowrap">
				<dt><fmt:message key="page.dict.dictTypeRemark"/>：</dt>
				<dd>
					<textarea rows="2" cols="100" name="remark">${dictType.remark}</textarea>
				</dd>
			</dl>	
		</fieldset>
		
		<fieldset>
			<legend><fmt:message key="page.dict.dictinfo"/></legend>
			
			<table class="list" style="width: 100%;" id="dictType_dict">
				<thead>
					<tr>
						<th width="5%"><input type="checkbox" group="codes" class="checkboxCtrl"></th>
						<th width="45%"><fmt:message key="page.dict.dictCode"/></th>
						<th width="50%"><fmt:message key="page.dict.dictName"/></th>
					</tr>
				</thead>
				<tbody>
					<c:if test="${not empty dictType.rmpDicts}">
						<c:forEach items="${dictType.rmpDicts}" var="dict">
							<tr>
								<td><input name="codes" type="checkbox"></td>
								<td>
									<input type="text" name="code" value="${dict.id.code}" onblur="tableLineUniqueValidator(this);" class="required">
								</td>
								<td>
									<input type="text" name="name" value="${dict.name}" class="required">
								</td>
							</tr>
						</c:forEach>
					</c:if>
				</tbody>
			</table>
			<div style="padding-top: 2px;">
				<a class="button" href="#" onclick="addRow('dictType_dict_template','dictType_dict');return false;"><span><fmt:message key="page.button.add"/></span></a>
				<a class="button" href="#" onclick="deleteRow('dictType_dict');return false;"><span><fmt:message key="page.button.delete"/></span></a>
			</div>
		</fieldset>
	</div>
	
	<div class="formBar">
		<ul>
			<c:if test="${readOnly ne '1'}">
					<li>
						<div class="buttonActive">
							<div class="buttonContent">
								<button type="submit"><fmt:message key="page.button.save"/></button>
							</div>
						</div>
					</li>
			</c:if>
			<li>
				<div class="button">
					<div class="buttonContent">
						<button type="button" class="close"><fmt:message key="page.button.cancel"/></button>
					</div>
				</div>
			</li>
		</ul>
	</div>
	</form>
	
	<table style="display: none;" id="dictType_dict_template">
		<tbody>
			<tr>
				<td><input name="codes" type="checkbox"></td>
				<td>
					<input type="text" name="code" onblur="tableLineUniqueValidator(this);"  class="required">
				</td>
				<td>
					<input type="text" name="name" class="required">
				</td>
			</tr>
		</tbody>
	</table>
</div>